USE ConsultTracking
GO
------------------------------------------------------------------
-- Insert Billing Methods
INSERT INTO [ConsultTracking].[dbo].[BillingMethod]
           ([Description])
     VALUES
           ('Monthly')

INSERT INTO [ConsultTracking].[dbo].[BillingMethod]
           ([Description])
     VALUES
           ('Hourly')
------------------------------------------------------------------
-- Create Job
go
DECLARE @CustomerID int
DECLARE @Description nvarchar(100)
DECLARE @BillingMethodID int
DECLARE @JobID int
DECLARE @Created smalldatetime
DECLARE @Modified smalldatetime

SET @CustomerID = 1
SET @Description = 'Our Test Job'
SET @BillingMethodID = 1

EXECUTE [ConsultTracking].[dbo].[CreateJob] 
   @CustomerID
  ,@Description
  ,@BillingMethodID
	,@JobID 
	,@Created
	,@Modified
-----------------------------------------------------------------
-- Create Task Pre-Assignment
DECLARE @LocationID int

SET @JobID = 1
SET @LocationID = 1
SET @Description = 'Monthly Maintenance'

EXECUTE [ConsultTracking].[dbo].[CreateTaskPreAssignment] 
   @JobID
  ,@LocationID
  ,@Description
-----------------------------------------------------------------
--  CreateTaskOnSite
DECLARE @StartTime smalldatetime
DECLARE @EndTime smalldatetime
DECLARE @Addressed bit
DECLARE @Status nvarchar(100)
DECLARE @UserID int

SET @JobID = 1
SET @LocationID = 1
SET @Description = 'Changed the video card in John''s Machine'
SET @StartTime = GETDATE()
SET @EndTime = GETDATE()
SET	@Addressed = 1
SET @Status = 'Success'
Set @UserID = 6

EXECUTE [ConsultTracking].[dbo].[CreateTaskOnSite] 
   @JobID
  ,@LocationID
  ,@Description
  ,@StartTime
  ,@EndTime
  ,@Addressed
  ,@Status
  ,@UserID
-----------------------------------------------------------------
--  Update Task
DECLARE @TaskID int

SET @TaskID = 1
SET @Description = 'Monthly Maintenance at the Main Office'
SET @StartTime = GETDATE()
SET @EndTime = GETDATE()
SET @Addressed = 0
SET @Status = 'The Task is Complete'

EXECUTE [ConsultTracking].[dbo].[UpdateTask] 
   @TaskID
  ,@Description
  ,@StartTime
  ,@EndTime
  ,@Addressed
  ,@Status

-----------------------------------------------------------------
--  Create Note
DECLARE @NoteID int

SET @TaskID = 1
SET @UserID = 1
SET @Description = 'All Computers serviced successfully'

EXECUTE [ConsultTracking].[dbo].[CreateNote] 
   @TaskID
  ,@UserID
  ,@Description
	,@NoteID
	,@Created
	,@Modified
-----------------------------------------------------------------
--  Update Note

SET @NoteID = 1
SET @UserID = 1
SET @Description = 'Service Done in record time'

EXECUTE [ConsultTracking].[dbo].[UpdateNote] 
   @NoteID
  ,@UserID
  ,@Description
	,@Modified

--test the if statement (one user trying to change another users note)
SET @NoteID = 1
SET @UserID = 2
SET @Description = 'This Customer was nothing but a huge pain in the ass.  I never want to do this job again.'

EXECUTE [ConsultTracking].[dbo].[UpdateNote] 
   @NoteID
  ,@UserID
  ,@Description
	,@Modified
-----------------------------------------------------------------
INSERT INTO [ConsultTracking].[dbo].[PurchaseOrder]
           ([TaskID]
           ,[Description]
		   ,[UserID]
           ,[Manufacturer]
           ,[ModelNumber]
           ,[Quantity]
           ,[Price])
     VALUES
           (1
           ,'15'' NetWork Cable to Move Marry''s Computer to new cubicle'
		   ,1
           ,'Regular Stock'
           ,'N/A'
           ,1
           ,5.00)
----------------------------------------------------------------
DECLARE @UserJobID int 

set @JobID = 1
set @UserID = 1

EXECUTE [ConsultTracking].[dbo].[AssignUserToJob] 
   @JobID
  ,@UserID
  ,@UserJobID OUTPUT
  ,@Created OUTPUT
  ,@Modified OUTPUT